package com.hzy.fivepalace.wx.controller.api;

import com.hzy.fivepalace.common.page.TableDataInfo;
import com.hzy.fivepalace.db.vo.wx.WxSubmitWithdrawDto;
import com.hzy.fivepalace.wx.annotation.LoginUser;
import com.hzy.fivepalace.wx.controller.base.BaseController;
import com.hzy.fivepalace.wx.service.WxGoodsService;
import com.hzy.fivepalace.wx.service.WxUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;

@RestController
@RequestMapping("/wx/user")
@Validated
@Api(tags = "用户服务")
public class WxUserController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(WxUserController.class);

    @Autowired
    private WxGoodsService wxGoodsService;

    @Autowired
    private WxUserService wxUserService;


    /**
     * 用户足迹
     *
     * @param userId   用户id
     * @param dataTime 日期：如2022-11-11
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/getUserFootprint")
    @ApiOperation(value = "用户足迹")
    public TableDataInfo getUserFootprint(
            @LoginUser @ApiParam(hidden = true) Integer userId,
            @ApiParam(value = "日期：如2022-11-11") @NotBlank @RequestParam(value = "dataTime") String dataTime,
            @ApiParam(value = "页码", defaultValue = "1") @RequestParam(defaultValue = "1") Integer page,
            @ApiParam(value = "分页大小", defaultValue = "10") @RequestParam(defaultValue = "10") Integer size) {

        return wxGoodsService.getUserFootprint(page, size, userId, dataTime);
    }

    /**
     * 用户信息
     * @param userId
     * @return
     */
    @GetMapping("/getUserInfo")
    @ApiOperation(value = "用户信息")
    public Object getUserInfo(@LoginUser @ApiParam(hidden = true) Integer userId) {

        return wxUserService.getUserInfo(userId);
    }

    /**
     * 获取用户团队列表
     * @param page
     * @param size
     * @param userId
     * @return
     */
    @GetMapping("/getUserTeamList")
    @ApiOperation(value = "获取用户团队列表")
    public TableDataInfo getUserTeamList(
            @ApiParam(value = "页码", defaultValue = "1") @RequestParam(defaultValue = "1") Integer page,
            @ApiParam(value = "分页大小", defaultValue = "10") @RequestParam(defaultValue = "10") Integer size,
            @LoginUser @ApiParam(hidden = true) Integer userId
    ) {
        return wxUserService.getUserTeamList(page, size,userId);
    }

    /**
     * 获取用户积分明细列表
     * @param page
     * @param size
     * @param userId
     * @return
     */
    @GetMapping("/getUserPointsDetailList")
    @ApiOperation(value = "获取用户积分明细列表")
    public TableDataInfo getUserPointsDetailList(
            @ApiParam(value = "页码", defaultValue = "1") @RequestParam(defaultValue = "1") Integer page,
            @ApiParam(value = "分页大小", defaultValue = "10") @RequestParam(defaultValue = "10") Integer size,
            @LoginUser @ApiParam(hidden = true) Integer userId
    ) {
        return wxUserService.getUserPointsDetailList(page, size,userId);
    }

    /**
     * 获取用户佣金信息
     * @param userId
     * @return
     */
    @GetMapping("/getUserCommissionInfo")
    @ApiOperation(value = "获取用户佣金信息")
    public Object getUserCommissionInfo(@LoginUser @ApiParam(hidden = true) Integer userId) {

        return wxUserService.getUserCommissionInfo(userId);
    }

    /**
     * 获取用户提现记录列表
     * @param page
     * @param size
     * @param userId
     * @return
     */
    @GetMapping("/getUserWithdrawRecordsList")
    @ApiOperation(value = "获取用户提现记录列表")
    public TableDataInfo getUserWithdrawRecordsList(
            @ApiParam(value = "页码", defaultValue = "1") @RequestParam(defaultValue = "1") Integer page,
            @ApiParam(value = "分页大小", defaultValue = "10") @RequestParam(defaultValue = "10") Integer size,
            @LoginUser @ApiParam(hidden = true) Integer userId
    ) {
        return wxUserService.getUserWithdrawRecordsList(page, size,userId);
    }

    /**
     * 获取用户佣金明细列表
     * @param page
     * @param size
     * @param userId
     * @return
     */
    @GetMapping("/getUserCommissionDetailList")
    @ApiOperation(value = "获取用户佣金明细列表")
    public TableDataInfo getUserCommissionDetailList(
            @ApiParam(value = "页码", defaultValue = "1") @RequestParam(defaultValue = "1") Integer page,
            @ApiParam(value = "分页大小", defaultValue = "10") @RequestParam(defaultValue = "10") Integer size,
            @LoginUser @ApiParam(hidden = true) Integer userId
    ) {
        return wxUserService.getUserCommissionDetailList(page, size,userId);
    }

    /**
     * 提现
     * @param dto
     * @param userId
     * @return
     */
    @PostMapping("/submitWithdraw")
    @ApiOperation(value = "提现")
    public Object submitWithdraw(@RequestBody WxSubmitWithdrawDto dto, @LoginUser @ApiParam(hidden = true) Integer userId) {

        return wxUserService.submitWithdraw(dto, userId);
    }

}
